package elements.axis ;
import string.Utils;

class YLabelStyle
{
	public var style:Dynamic;

	public function new( json:Dynamic, name:String )
	{

		this.style = {	size: 10,
				color: 0x000000,
				show_labels: true
		};

		var comma: Float;
		var none: Float;
		var tmp:Array<String>;
		
		if( Reflect.hasField(json,'name'+'_label_style') == null )
			return;
				
		// is it CSV?
		var label_style : String = Reflect.field(json,'name'+'_label_style');
		comma = label_style.lastIndexOf(','); // TODO - check if lastIndexOf is a member
			
		if( comma<0 )
		{
			none = label_style.lastIndexOf('none',0);
			if( none>-1 )
			{
				this.style.show_labels = false;
			}
		}
		else
		{
			tmp = label_style.split(',');
			if( tmp.length > 0 )
				this.style.size = tmp[0];
				
			if( tmp.length > 1 )
				this.style.color = Utils.get_color(tmp[1]);
		}
	}
}
